package cloud.shyidong.admin.tentant.controller;

import cloud.shyidong.admin.tenant.service.TenantPayService;
import cloud.shyidong.core.controller.AbstractController;
import cloud.shyidong.core.request.LongIdRequest;
import cloud.shyidong.tenant.dao.TenantPayDao;
import cloud.shyidong.tenant.entity.TenantPayEntity;
import cloud.shyidong.tenant.request.TenantPayInsertRequest;
import cloud.shyidong.tenant.request.TenantPayPageRequest;
import cloud.shyidong.tenant.request.TenantPaySaveRequest;
import cloud.shyidong.tenant.request.TenantPayUpdateRequest;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 租户支付控制器
 * </p>
 *
 * @author syd
 * @since 2023-09-15 11:29:43
 */
@RestController
@RequestMapping("/tenant-pay")
@Slf4j
public class TenantPayController extends AbstractController<TenantPayService, TenantPayDao, TenantPayEntity, LongIdRequest, TenantPayInsertRequest, TenantPayUpdateRequest, TenantPayPageRequest> {
    
    @GetMapping("/get")
    public TenantPayEntity getByTenantId(@Valid LongIdRequest longIdRequest) {
        if (log.isDebugEnabled()) {
            log.debug("get param >>> {}", JSON.toJSONString(longIdRequest));
        }
        return getService().getByTenantId(longIdRequest.getId());
    }
    
    @PostMapping("/save")
    public TenantPayEntity save(@RequestBody @Valid TenantPaySaveRequest tenantPaySaveRequest) {
        if (log.isDebugEnabled()) {
            log.debug("save param >>> {}", JSON.toJSONString(tenantPaySaveRequest));
        }
        return getService().save(tenantPaySaveRequest);
    }
    
}

